On the Subject of Cruel Modulo

Remember that super easy mathematical module? Here’s his evil twin.

  • This modulo shows three numbers, a keypad, and a small screen at the bottom which will display the answer.
  • Take the larger central number (n), raise it to the power of the smaller number in the top right (p), and then modulo this result by the smaller number in the top left (m).
  • To perform the modulo operation, multiply n by itself p times, then take this number subtract m from it repeatedly until it is less than m.
  • Alternatively, divide n^p by m and take the remainder.
  • Whichever method you prefer to use, once you have calculated the correct answer, enter it into the keypad and press the green submit button. The module will only process if at least a digit is inputted.
  • To clear your answer, press the red clear button.
  • Entering the correct answer will disarm the module. Entering an incorrect answer will cause a strike and reset both m and n, but NOT p.

For an alternative method:

  1. Take n, modulo m.
  2. Let a variable, t, equals 1.
  3. Take the result, multiplied by n, modulo m.
  4. Add 1 to t.
  5. Repeat step 3 and 4 until t is equal to p, or the result got is the same as n modulo m.
  6. If t is equal to p, the result currently is the answer.
  7. If the result got is the same as n modulo m, take p, modulo t-1.
  8. If the result is 0, use t-1.
  9. List down the pattern, and label it from 1, then 2, 3, and so on.
  10. Take the result and find the label that is the same as the result found in step 7 and 8.
  11. The result found is your answer.